package cn.jiyun.service.impl;


import cn.jiyun.entity.Locationinfo;
import cn.jiyun.mapper.LocationinfoMapper;
import cn.jiyun.service.LocationinfoService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
* @author 31511
* @description 针对表【locationinfo】的数据库操作Service实现
* @createDate 2024-10-29 15:33:52
*/
@Service
public class LocationinfoServiceImpl extends ServiceImpl<LocationinfoMapper, Locationinfo>
    implements LocationinfoService {

    @Override
    public Page<Locationinfo> findPage(Integer pageNum, Integer pageSize, Locationinfo location) {
        Page<Locationinfo> page = new Page<>(pageNum,pageSize);
        LambdaQueryWrapper<Locationinfo> wrapper = new LambdaQueryWrapper<>();
        if (!StringUtils.isEmpty(location.getName())) {
            wrapper.like(Locationinfo::getName,location.getName());
        }
        if (!StringUtils.isEmpty(location.getIdNumber())) {
            wrapper.like(Locationinfo::getIdNumber,location.getIdNumber());
        }
        if (!StringUtils.isEmpty(location.getDeviceId())) {
            wrapper.like(Locationinfo::getDeviceId,location.getDeviceId());
        }
        Page<Locationinfo> page1 = baseMapper.selectPage(page, wrapper);
        return page1;
    }

    @Override
    public Locationinfo toDw(Integer id) {
        Locationinfo locationinfo = baseMapper.selectById(id);
        return locationinfo;
    }
}




